<template>
	<view>
		<view class="all">
			<view class="title">
				<text>修改个人信息</text>
			</view>
			<view class="line"></view>
			<view class="row">
				<text class="text">邮箱</text>
				<input class="input" decode="true" @input="onKeyemailInput" v-model="email"></input>
			</view>
			<view class="line"></view>
			<view class="row">
				<text class="text">电话</text>
				<input class="input" decode="true" @input="onKeytelephoneInput" v-model="telephone"></input>
			</view>
			<view class="line"></view>
			<button type="primary" @click="send">提交</button>
		</view>
		</view>
</template>

<script>
	import{udStudentInfo,udTeacherInfo,udEnterpriseInfo}
	from '@/api/my/service.js'
	export default {
		data() {
			return {
				email:"",
				telephone:"",
			}
		},
		onLoad(){
			this.getdata();
		},
		methods: {
			onKeyemailInput: function(event) {
				this.email = event.target.value
			},
			onKeytelephoneInput: function(event) {
				this.telephone = event.target.value
			},
			getdata(){
				const data = uni.getStorageSync("Infomation");
				const role = uni.getStorageSync("role");
				if(role == "enterprise"){
					this.telephone = data.linkTel;
				}else{
					this.telephone = data.telephone;
				}
				this.email = data.email;
				console.log("---"+this.email+"---"+this.telephone);
			},
			send(){
				var data = uni.getStorageSync("Infomation");
				var role = uni.getStorageSync("role");
				console.log(role);
				if(role == "student"){
				//学生
				console.log(data.stuId,this.email,this.telephone,data.className,data.name,data.stuNumber,data.stationName,data.wechatNum,data.password,data.remark);
				udStudentInfo(data.stuId,this.email,this.telephone,data.className,data.name,data.stuNumber,data.stationName,data.wechatNum,data.password,data.remark).then(res=>{
					console.log("---"+res.data);
					console.log(JSON.stringify(res));
				}).catch(res=>{
						console.log("nook?"+res);
				});
				uni.redirectTo({
					url:"/pages/my/student/info"
				});
				}else if(role == "teacher"){
				//教师
				console.log(data.tId,this.email,this.telephone,data.jobNum,data.name,data.wechatNum,data.password,data.remark);
				udTeacherInfo(data.tId,this.email,this.telephone,data.jobNum,data.name,data.wechatNum,data.password,data.remark).then(res=>{
					console.log("---"+res.data);
				}).catch(res=>{
					console.log("nook?"+res.data);
				});
				uni.redirectTo({
					url:"/pages/my/teacher/info"
				})
				}else if(role == "enterprise"){
				//企业
				console.log(data.eId,this.email,this.telephone,data.name,data.website,data.introduction,data.linkPerson,data.password,data.remark);
				udEnterpriseInfo(data.eId,this.email,this.telephone,data.name,data.website,data.introduction,data.linkPerson,data.password,data.remark).then(res=>{
					console.log("---"+res.data);
				}).catch(res=>{
					console.log("nookqwe?"+res.data);
				});
				uni.redirectTo({
					url:"/pages/my/company/infodetail"
				});
			}
			}
		}
	}
</script>

<style>
	body{
		
	}
	.all{
		margin-top: 30rpx;
		margin-left: 10rpx;
	}
	.input{
		width: 50%;
		border: 1px solid #e5e5e5;
		border-radius: 30px;
	}
	.title {
		color: rgba(78, 78, 78, 1);
		text-align: center;
		font-weight: bold;
	}
	.title text {
		font-size: 13pt;
	}
	.row {
		color: rgba(78, 78, 78, 1);
	}
	
	.row text {
		padding-left: 30rpx;
		font-size: 10pt;
	}
	
	.row input {
		padding-top: 5rpx;
		padding-left: 20rpx;
		font-size: 9pt;
		margin-left: 10px;
	}
	.line {
		white-space: normal;
		width: 749upx;
		padding: 0upx;
		clear: both;
		margin-top: 36upx;
		margin-left: 0upx;
		float: left;
		background-color: #e1e1e1;
		text-align: left;
		border-radius: 0upx;
		font-size: 2upx;
		line-height: 3upx;
	}
	button[type=primary] {
		background-color: rgba(53, 125, 197, 1);
	}
	
	button {
		color: #fff;
		width: 90%;
		border-radius: 30px;
		/* 		line-height: 2.1; */
	}
	
	button::after {
		color: #fff;
		border: 1px solid rgba(53, 125, 197, 1);
	}
</style>
